var basePath;
$(function(){
	rebateApply();
	basePath = $("#basePath");
});
/**提取金额**/
var rebateApply = function (){
	$(".btn_login_submit").on("click",function(){
		var user_id = $("#user_id").val();
		var over_money = $(".over_money").text();//余额
		var payee_name = $("#payee_name").val();//提款人姓名
		var payee_card_number = $("#payee_card_number").val();//银行卡号
		var money = $("#money").val();//提取金额
		var payee_phone = $("#payee_phone").val();
		var activty_code = $("#activty_code").val();
		var phone_reg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(14[0-9]{1})|(17[0-9]{1}))+\d{8})$/; 
		var input_money_reg = /^(([1-9]\d{0,9})|0)(\.\d{1,2})?$/;
		var card_reg = /^(\d{16}|\d{19})$/;
		
		if($.trim(over_money) == "0"){
			layer.open({
			    content:'您当前余额不足无法完成提现',
			    time: 2
			});
			return false;
		}
		if($.trim(payee_name).length <=0){
			layer.open({
			    content:'请输入提款人姓名',
			    time: 2
			});
			return false;
		}
		if(money.length<=0){
			layer.open({
			    content:'请输入提取金额',
			    time: 2
			});
			return false;
		}
		if(!input_money_reg.test(money)) 
		{ 
			layer.open({
			    content:'请输入有效的提取金额',
			    time: 2
			}); 
		    return false; 
		}
		if(Number(over_money) <Number(money)){
			layer.open({
			    content:'余额不足',
			    time: 2
			});
			return false;
		}
		if($.trim(payee_card_number).length <=0){
			layer.open({
			    content:'请输入银行卡号',
			    time: 2
			});
			return false;
		}
		if(!card_reg.test(payee_card_number)){
			layer.open({
			    content:'请输入合法的银行卡号',
			    time: 2
			});
			return false;
		}
		if($.trim(payee_phone).length<=0){
			layer.open({
			    content:'请输入手机号码',
			    time: 2
			});
			return false;
		}
		if(!phone_reg.test(payee_phone)){
			layer.open({
			    content:'请输入合法的手机号码',
			    time: 2
			});
			return false;
		}
	
		var params= {id:user_id,money:money,payeeName:payee_name,payeeCardNumber:payee_card_number,payeePhone:payee_phone};
		
		$.ajax({
			url: "userApply",
			data:params,  
			type:'post',   
			dataType:'json',  
			success:function(msg){
				if(msg == 0){
					layer.open({
					    content:'正在处理在两个小时之后请查收',
					    time: 2
					});
				}else{
					//提示错误信息
				}
				
			},
			error:function(msg){
				layer.open({
				    content:'提取现金失败!',
				    time: 2
				});
			}
		});
	})
}